import 'package:carousel_slider/carousel_slider.dart';
import 'package:flutter/material.dart';

import 'newHomeNav .dart';

class Newshome extends StatefulWidget {
  const Newshome({super.key, required this.list});
  final List list;

  @override
  _NewhomeState createState() => _NewhomeState();
}

class _NewhomeState extends State<Newshome> {
  Widget getSwiper() {
    return CarouselSlider(
      items: [
        Image.network(
          "https://img2.baidu.com/it/u=751773882,1290172297&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img0.baidu.com/it/u=4243928860,573227806&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img0.baidu.com/it/u=2290894967,2752394478&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800",
          fit: BoxFit.cover,
        ),
        Image.network(
          "https://img2.baidu.com/it/u=667247897,766454330&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=500",
          fit: BoxFit.cover,
        )
      ],
      options: CarouselOptions(
          height: 200,
          autoPlay: true,
          autoPlayInterval: const Duration(seconds: 2)),
    );
  }

  //轮播图搜索框
  search() {
    return Container(
        padding: const EdgeInsets.all(10),
        margin: const EdgeInsets.all(5),
        decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(20), color: Colors.white),
        child: const Row(children: [
          Icon(Icons.search),
          SizedBox(width: 10),
          Text(
            '请搜索你需要的商品',
            style: TextStyle(color: Colors.grey),
          )
        ]));
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(children: [
        search(),
        getSwiper(),
        Newhomenav(navList: widget.list)
      ] // 轮播图],
          ),
    );
  }
}
